package com.coffee.middleware.dict.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.coffee.core.ValidGroup;
import com.coffee.mybatis.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * @author songkui
 * @since 2024/5/9 14:54
 */
@Schema(description = "字典类型")
@Getter
@Setter
@EqualsAndHashCode(of ={"id"}, callSuper = false)
@Accessors(chain = true)
@NoArgsConstructor
@TableName("sys_dict_type")
public class DictTypeEntity extends BaseEntity {

    @NotNull(groups = ValidGroup.Update.class, message = "ID不能为空")
    @Null(groups = ValidGroup.Create.class, message = "ID必须为空")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "字典类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "名称必填")
    @TableField("type_name")
    private String typeName;


    @Schema(description = "字典类型编码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(groups = ValidGroup.Create.class, message = "类型编码必填")
    @TableField("type_code")
    private String typeCode;

    @Schema(description = "是否系统字典", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "是否系统字典必填")
    @TableField("sys_bit")
    private Boolean sysBit;

    @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
    @TableField("remark")
    private String remark;



    public DictTypeVO buildDictTypeVO(){
        DictTypeVO dictTypeVO = new DictTypeVO();
        dictTypeVO.setId(this.id);
        dictTypeVO.setTypeName(this.typeName);
        dictTypeVO.setTypeCode(this.typeCode);
        return dictTypeVO;
    }


}
